package com.ruoyi.web.wrapper;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.wrapper.BaseControllerWrapper;
import com.ruoyi.merchantdata.enums.DataStatusEnum;
import com.ruoyi.merchantdata.enums.StarTypeEnum;

import java.util.List;
import java.util.Map;

public class MemberDataPoolInfoWrapper extends BaseControllerWrapper {

    public MemberDataPoolInfoWrapper(Map<String, Object> single) {
        super(single);
    }

    public MemberDataPoolInfoWrapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {
            handleEnumFields(map);
            handleEnumField(map);
            Long uid = (Long) map.get("uid");
            if (ObjectUtil.isNotEmpty(uid)){
                map.put("uid", uid+"");
            }

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }

    private void handleEnumFields(Map<String, Object> map) {
        Integer starNumber = (Integer) map.get("starNumber");
        String starNumberName = StarTypeEnum.getNameByValue(starNumber);
        map.put("starNumberName", starNumberName);
    }

    private void handleEnumField(Map<String, Object> map) {
        Integer stateInfo = (Integer) map.get("stateInfo");
        String stateInfoName = DataStatusEnum.getNameByValue(stateInfo);
        map.put("stateInfoName", stateInfoName);
    }

}
